function TimeFilter(ops) {
    var options = ops;
    var filter = {
        init: function () {
            this._initFilter();
        },

        getParameter: function() {
            var param = this._getParam(this._selectIndex);
            return param;
        },

        _initFilter: function () {
            var container = $("#div_time_filter");
            if(!container) {
                return;
            }

            var scope = $("body").scope();

            var time_filter = options.filters;

            var select = "";
            var html = "<div class='btn-group  margin-l5'>";
            for (var i = 0; i < time_filter.length; i++) {
                var c = i==0?"timefilter_select":"";
                if(i == 0) {
                    select = "#timeType_btn_"+ i;
                }
                html += "<span id='timeType_btn_"+ i +"' type='button' class='btn btn-info margin-v5 "+c+"' " +
                    "ng-click=\"onTimeFilter(" + i + ")\">" + time_filter[i] + "</span>";
            }
            html += "</div>";
            var el = scope.compile(html)(scope);
            container.html(el);
            this._current = select;
            this._selectIndex = 0;

            scope.safeApply(function () {
                scope.onTimeFilter = function (index) {
                    this._selectIndex = index;
                    var c = "#timeType_btn_"+index;
                    if(this._current != c) {
                        var param = this._getParam(index);
                        options.handler(param);
                    }
                    if(this._current) {
                        $(this._current).removeClass("timefilter_select");
                    }
                    this._current = c;
                    $(this._current).addClass("timefilter_select");
                }.bind(this);
            }.bind(this));
        },

        _getParam: function(index) {
            var param = {
                timeType: index
            };

            return param;
        }
    };
    filter.init();
    return filter;
};